package com.ggstream.ui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

import com.ggstream.Application;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Fenetre extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Fenetre frame = new Fenetre();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Fenetre() {
		setTitle("GG-stream");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnFichier = new JMenu("Fichier");
		menuBar.add(mnFichier);
		
		JMenuItem mntmNouveauSiteWeb = new JMenuItem("Nouveau projet");
		mntmNouveauSiteWeb.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent arg0) {
				//default icon, custom title
				int n = JOptionPane.showConfirmDialog(
				    null,
				    "Nouveau projet ?",
				    "Nouveau projet",
				    JOptionPane.YES_NO_OPTION);
				
				if (n==JOptionPane.YES_OPTION) {
					Application.get().nouveauProjet() ;
					nouveauProjet() ;
				}
			}
		});
		mnFichier.add(mntmNouveauSiteWeb);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
	}

	@SuppressWarnings("deprecation")
	// TODO replacer le .show() par autre chose, je ne sais pas quoi.
	protected void nouveauProjet() {
		this.setContentPane(new PanneauProjet()) ;
		this.show();
		//this.pack() ;
	}

}
